package sso.service;

import bean.UserInfo;
import org.springframework.stereotype.Service;

import java.util.HashMap;

@Service
public class UserService {
    private  static HashMap<String,UserInfo> userMap ;
    static {
        //初始化合法用户列表
        userMap=new HashMap<>();

        UserInfo u1 = new UserInfo();
        u1.setUsername("rudolf");
        //123456  MD5
        u1.setPassword("e10adc3949ba59abbe56e057f20f883e");
        UserInfo u2 = new UserInfo();
        u2.setUsername("admin");
        u2.setPassword("e10adc3949ba59abbe56e057f20f883e");
        userMap.put("rudolf",u1);
        userMap.put("admin",u2);

    }

    public UserInfo getUserByName(String name){
        if(userMap.containsKey(name)){
            UserInfo userInfo = userMap.get(name);
            return userInfo;
        }else{
            return null;
        }

    }

}
